Embedded Probabilistic Programming
نویسندگان
چکیده
We propose to represent a probability distribution as a program in a general-purpose programming language rather than a special language built from scratch. This approach makes it easier for the probabilistic-reasoning and programming-language communities to share their work. To demonstrate that this representation is simple and efficient, we implement inference by variable elimination and importance sampling using the concepts of reflection, memoization, and continuations. The embedded approach to probabilistic programming is to build a library that extends a generalpurpose host language with probabilistic constructs. Seen from within the host language, these embedded constructs are ordinary functions with side effects. For example, the two most important constructs are dist, a function that maps a list of probability-value pairs to a randomly chosen value, and fail, a function that takes no input and never returns because it observes an impossible event. The following program, written in the general-purpose programming language OCaml, expresses the distribution over a pair of fair coin flips, conditional on at least one of them being true. let coin_flip () = dist [ (0.5, V true); (0.5, V false) ] in let x = coin_flip () in let y = coin_flip () in if x || y then (x,y) else fail () (1) The variables x and y above are host-language variables that represent random variables. The embedded approach has several advantages over building a probabilistic language from scratch. • It is easy to learn and implement, because host-language features are reused such as compilers, I/O libraries, database interfaces, timing facilities, data structures, and type checking. • It can compile stochastic models to machine code. Deterministic parts of the models run as fast as in the host language, without the overhead imposed by non-embedded interpreters. • It treats probability distributions as an abstract container data-type. This treatment makes it natural to describe distributions over distributions, which are useful for modeling multiagent interactions with imperfect information. For the library not to just perform naı̈ve rejection sampling, the host language needs certain features other than random-number generation [2]. We use the delimited control operators shift and reset in the host language OCaml [5]. Embedded probabilistic programming essentially builds a library of weighted nondeterminism that turns the host-language compiler into a probabilistic-language compiler, so any improvement in the host-language implementation results in more efficient inference. To illustrate how inference algorithms correspond to library implementation strategies and host-language concepts, we present two implementations: one performing exact inference by enumeration and variable elimination [1], and one performing approximate inference by importance sampling and evidence pushing [6]. The implementations are short (totaling 200 lines), expressive, and available online along with tests.
منابع مشابه
Using Probabilistic-Risky Programming Models in Identifying Optimized Pattern of Cultivation under Risk Conditions (Case Study: Shoshtar Region)
Using Telser and Kataoka models of probabilistic-risky mathematical programming, the present research is to determine the optimized pattern of cultivating the agricultural products of Shoshtar region under risky conditions. In order to consider the risk in the mentioned models, time period of agricultural years 1996-1997 till 2004-2005 was taken into account. Results from Telser and Kataoka mod...
متن کاملMulti-item inventory model with probabilistic demand function under permissible delay in payment and fuzzy-stochastic budget constraint: A signomial geometric programming method
This study proposes a new multi-item inventory model with hybrid cost parameters under a fuzzy-stochastic constraint and permissible delay in payment. The price and marketing expenditure dependent stochastic demand and the demand dependent the unit production cost are considered. Shortages are allowed and partially backordered. The main objective of this paper is to determine selling price, mar...
متن کاملRandomized Algorithms and Probabilistic Analysis in Wireless Networking
Devices connected wirelessly, in various forms including computers, hand-held devices, ad hoc networks, and embedded systems, are expected to become ubiquitous all around us. Wireless networks pose interesting new challenges, some of which do not arise in standard (wired) networks. This survey discusses some key probabilistic notions – both randomized algorithms and probabilistic analysis – in ...
متن کاملProgramming under Probabilistic Constraints with a Random Technology Matrix
Probabilistic constraint of the type P (Ax ≤ β) ≥ p is considered and it is proved that under some conditions the constraining function is quasi-concave. The probabilistic constraint is embedded into a mathematical programming problem of which the algorithmic solution is also discussed.
متن کاملA Distributed and Probabilistic Concurrent Constraint Programming Language
We present a version of the CCP paradigm, which is both distributed and probabilistic. We consider networks with a fixed number of nodes, each of them possessing a local and independent constraint store. While locally the computations evolve asynchronously, following the usual rules of (probabilistic) CCP, the communications among different nodes are synchronous. There are channels, and through...
متن کامل